package test00;

import java.lang.reflect.Method;
import java.util.Random;

/**
 * @Author zqx
 * @Date 2024-03-27
 */
public class Student {
    private String name;
    private int age;
    private Double score;

    public Student(){}
    public Student(String name, Double score) {
        this.name = name;
        this.score = score;
    }

    public Student(String name, int age, Double score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Double getScore() {
        return score;
    }

    public void setScore(Double score) {
        this.score = score;
    }

    private int study(String address, Double hour) throws Exception {
        // 返回 1-100 的随机数，表示学习获取的经验值
        // Random rand = new Random();
        // return rand.nextInt(101) + 1 ;
        System.out.println(this.name + "在" + address + "学习了" + hour + "个小时");

        Class<?> randomClass = Random.class;
        Object rand = randomClass.getConstructor().newInstance();

        Method nextIntMethod = randomClass.getMethod("nextInt", int.class);
        Object data = nextIntMethod.invoke(rand, 100);

        if (data instanceof Integer) {
            Integer jinYan = (Integer) data;
            return jinYan + 1;
        }
        return -1;
    }


    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }
}
